import datetime


class User:
    def __init__(self, account, password, username):
        self.account = account
        self.password = password
        self.username = username
        self.recv_messages = []


class Message:
    def __init__(self, sender, recipient, text):
        self.sender = sender
        self.recipient = recipient
        self.text = text
        self.time = datetime.datetime.now(tz=datetime.timezone(datetime.timedelta(hours=8)))  # UTC+0800

    def as_view(self):
        return {
            'time': {
                'year': self.time.year,
                'month': self.time.month,
                'day': self.time.day,
                'hour': self.time.hour,
                'minute': self.time.minute,
                'second': self.time.second
            },
            'sender': self.sender,
            'recipient': self.recipient,
            'text': self.text
        }
